import java.util.Arrays;

public class Code {
    public void rotate(int[] nums, int k) {
       for(int i = 0 ; i < k ; i++){
           int x = nums[nums.length - 1];
           for (int j = nums.length - 2 ; j >= 0; j--){
               nums[j + 1] = nums[j];
           }
           nums[0] = x;
       }
    }

    public static void main(String[] args) {
        int[] array = {1,2,3,4,5,6,7};
        Code code = new Code();
        for(int x : array){
            System.out.print(x + " ");
        }
        System.out.println();
        code.rotate(array,3);
        for(int x : array){
            System.out.print(x + " ");
        }
    }
}
